project(fcgirouter)

cmake_minimum_required(VERSION 2.6.2)

include(CheckFunctionExists)

enable_testing()

# Library tests
find_path( LIBEVENT_INCLUDE event.h PATHS /usr/include/ /usr/local/include/ )
find_library( LIBEVENT_LIBRARY event PATHS /usr/lib/ /usr/local/lib/ )

# stdc features
set( CMAKE_REQUIRED_DEFINITIONS _GNU_SOURCE )

Check_Function_Exists( strndup HAVE_STRNDUP )
Check_Function_Exists( strnlen HAVE_STRNLEN )

if( HAVE_STRNDUP OR HAVE_STRNLEN )
	add_definitions( _GNU_SOURCE )
endif( HAVE_STRNDUP OR HAVE_STRNLEN )

configure_file( config.h.in config.h )

include_directories( ${LIBEVENT_INCLUDE} 	)
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )

set( common_SOURCES connection.c dualfifo.c fcgiparse.c portable.c )
set( common_HEADERS connection.h dualfifo.h fcgiparse.h portable.h tunable.h )

set( application_SOURCES proxy.c )
set( application_HEADERS )

set( generated_HEADERS config.h )

add_executable( fcgirouter 
	${common_SOURCES}
	${common_HEADERS}
	${application_SOURCES}
	${application_HEADERS}
	${generated_HEADERS}
	)

target_link_libraries( fcgirouter ${LIBEVENT_LIBRARY} )

# Tests
#add_test( dualfifo_test 
#		dualfifo_test
#	)
